<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue实现60s倒计时</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <style>
        .abc {
            color: red;
        }
    </style>
</head>
<body>
    <div id="app">
        <p :class="cla">{{ time + '秒' }}</p>
    </div>
    <script>
        const { createApp, ref } = Vue
        createApp({
            setup() {
                const time = ref(60)
                const cla = ref('')
                const i = setInterval(() => {
                    time.value --
                    if(time.value <= 10) {
                        cla.value = 'abc'
                    }
                    if(time.value <= 0) {
                        clearInterval(i)
                    }
                }, 1000)
                return {time, cla}
            }
        }).mount('#app')
    </script>
</body>
</html>